package cdu.hjx.project.sys.service.impl;

import cdu.hjx.project.pojo.Employee;
import cdu.hjx.project.sys.mapper.EmployeeMapper;
import cdu.hjx.project.sys.service.EmployeeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Resource
    private EmployeeMapper employeeMapper;

    @Override
    public int add(Employee employee) throws Exception {
        return employeeMapper.add(employee);
    }

    @Override
    public Employee findByUsername(String username) throws Exception {
        return employeeMapper.findByUsername(username);
    }

    @Override
    public List<Employee> employees() throws Exception {
        return employeeMapper.employees();
    }

    @Override
    public int insert(Employee employee) throws Exception {
        Employee employeeName = findByUsername(employee.getUusername());
        return null == employeeName ? employeeMapper.add(employee) : -1;
    }

    @Override
    public Employee login(String username, String password) throws Exception {
        return employeeMapper.login(username, password);
    }
}
